//
//  UITableView+ZCHelp.m
//  UniversalApp
//
//  Created by 凯朱 on 2019/6/16.
//  Copyright © 2019 徐阳. All rights reserved.
//

#import "UITableView+ZCHelp.h"


@implementation UITableView (ZCHelp)
/*
 添加下拉刷新
 
 @param refreshingBlock 下拉刷新回调
 */
-(void)addHeadRefreshWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock
{
    self.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        if (refreshingBlock) {
            refreshingBlock();
        }
    }];
}

/*
 停止下拉刷新
 */
-(void)stopHeadRefresh
{
    [self.mj_header endRefreshing];
}

/*
 停止下拉加载更多
 */
-(void)stopFooterRefresh
{
    [self.mj_footer endRefreshing];
}

/**
 添加上拉加载更多
 
 @param refreshingBlock 下拉刷新回调
 */
-(void)addFooterRefreshWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock
{
    self.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
        if (refreshingBlock) {
            refreshingBlock();
        }
    }];
}

-(void)endRefresh{
    if (self.mj_header.isRefreshing) {
        self.mj_header.hidden = NO;
        [self.mj_header endRefreshing];
    }
    if (self.mj_footer.isRefreshing) {
        self.mj_footer.hidden = NO;
        [self.mj_footer endRefreshing];
    }
}
@end
